const RootURL = $('#RootURL').val(); // || '/';
const SessionUserId = $('#SessionUserId').val();

// console.log(RootURL);
// console.log(SessionUserId);

const templateSettings = {
    evaluate: /\{\{(.+?)\}\}/g,
    interpolate: /\{\{=(.+?)\}\}/g,
    escape: /\{\{-(.+?)\}\}/g
};

let getUrlParams = function () {
    let args = {};
    let query = location.search.substring(1);
    let pairs = query.split('&');
    for (let i = 0; i < pairs.length; i += 1) {
        let pos = pairs[i].indexOf('=');
        if (pos !== -1) {
            let argName = pairs[i].substring(0, pos);
            args[argName] = pairs[i].substring(pos + 1);
        }
    }
    return args;
};

let toDate = function (datetime) {
    if (datetime) {
        var re = /\d{4}-\d{2}-\d{2}/;
        var res = re.exec(datetime);
        //console.log(res);
        if (res) {
            return res[0];
        } else {
            return '';
        }
    } else {
        return datetime;
    }
};

let FormDataToJson = function (formData) {
    var objData = {};
    formData.forEach((value, key) => objData[key] = value);
    //return JSON.stringify(objData);
    return objData;
};

let sleep = function (delay) {
    let start = (new Date()).getTime();
    while (((new Date()).getTime() - start) < delay) {
        continue;
    }
};